package com.spark.shiro.bean;

import java.util.List;

/**
 * Created by tyd on 2017-10-30.
 */
public class PageBean<T> {

    //当前页
    private int currentPage;

    //总数
    private int total;

    //总页数
    private int totalPage;

    //当前页起始位置
    private int index;

    //每页显示数量
    private int pageNum = 5;

    private List<T> data;

    public int getCurrentPage() {
        return currentPage;
    }

    public PageBean() {

    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;

        if (pageNum > 0) {
            this.pageNum = this.getPageNum();
        }
        if (total > 0) {
            this.totalPage = (int) Math.ceil(total / pageNum);
        }

        this.index = (currentPage - 1) * pageNum;

    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
